import { defineStore } from 'pinia'

export const useMenuStore = defineStore('menu', {
    state: () => ({
        sidebarCollapse: true,
        menuList: [],
    }),
    actions: {
        setMenuList(menuList) {
            this.menuList = menuList;
        },
        toggleSideBar() {
            this.sidebarCollapse = !this.sidebarCollapse
        }
    },
    getters: {
        getMenuList: (state) => {
            return state.menuList
        },
        getSideBarCollapse: (state) => {
            return state.sidebarCollapse
        },
    },
    persist: {
        enabled: true,
        strategies: [
            {
                key: 'menu',
                storage: localStorage,
                path:[] //可以选择保存的字段  其余的不保存
            }
        ]
    }
})

